package com.baidu.dao;

import com.baidu.pojo.Order;
import com.baidu.pojo.Ticket;
import com.baidu.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TicketMapper {
    //    查询票务信息
    @Select("SELECT * FROM ticket WHERE eid=#{eid} and tstate=0")
    public List<Ticket> getAllTicket2(Integer eid);

    //添加门票
    @Insert("INSERT INTO ticket (tname,tsession,tmoney,tnum,tstate,eid,t_start_time,t_end_time) \n" +
            "VALUES(#{tname},#{tsession},#{tmoney},#{tnum},0,#{eid},#{t_start_time},#{t_end_time})")
    public void addTicket(Ticket ticket);

    //根据id修改门票信息
    @Update("UPDATE ticket SET tname=#{tname},tsession=#{tsession},tmoney=#{tmoney},tnum=#{tnum},eid=#{eid},t_start_time=#{t_start_time},t_end_time=#{t_end_time} \n" +
            "WHERE tid=#{tid}")
    public void updateTicket(Ticket ticket);

    //删除门票
    @Update("update ticket set tstate=1 where tid=#{tid}")
    public void deleteTicket(Integer tid);

    //查询所有门票
    public List<Ticket> getAllTicket();

    //分页查询所有用户信息,以及关联的角色信息 第一个参数表示起始位置，第二个参数表示页面容量
    public List<Ticket> getByPage(@Param("start")Integer start, @Param("pageSize")Integer pageSize);

    //分页查询总记录数
    @Select("select COUNT(*) from ticket where tstate!=1")
    public int count();

    //根据id查询指定的展会信息
    public  Ticket getTicketByEid(Integer eid);

    //根据id查询指定的门票信息
    @Select("select * from ticket where tid=#{tid}")
    public  Ticket getTicketByTid(Integer tid);
}
